import 'package:dio/dio.dart';

Dio initAjax() {
  BaseOptions options = new BaseOptions(
    baseUrl: "http://jd.itying.com/",
    connectTimeout: 8000,
    receiveTimeout: 8000,
  );
  Dio dio = new Dio(options);
  dio.interceptors
      .add(InterceptorsWrapper(onRequest: (RequestOptions options) async {
    // Do something before request is sent
    print("send");
    print(options.uri);
    return options; //continue
    // If you want to resolve the request with some custom data，
    // you can return a `Response` object or return `dio.resolve(data)`.
    // If you want to reject the request with a error message,
    // you can return a `DioError` object or return `dio.reject(errMsg)`
  }, onResponse: (Response response) async {
    // Do something with response data
    print("receive");
    return response; // continue
  }, onError: (DioError e) async {
    // Do something with response error
    print("err");
    print(e);
    return e; //continue
  }));
  return dio;
}

class ApiBase {
  static Dio dio = initAjax();
  static String baseURL = "http://jd.itying.com/";
}
